//
//  SearchController.m
//  CMJWeibo
//
//  Created by BH on 15/12/4.
//
//

#import "SearchController.h"
#import "SearchBar.h"
#import "CMJCommonGroup.h"
#import "CMJCommonArrowItem.h"
#import "MoreController.h"
#import "CMJCommonCell.h"

@interface SearchController ()

@property(nonatomic,strong)SearchBar *searchBar;

@end

@implementation SearchController

-(void)viewDidLoad
{
    [super viewDidLoad];
    
    // 导航栏中间放一个搜索框
    [self setupSearchBar];
    
    // 初始化模型数据
    [self setupItems];
}

/**
 *  搜索框
 */
-(void)setupSearchBar
{
    SearchBar *searchB = [[SearchBar alloc] init];
    searchB.frame = CGRectMake(0, 0, self.view.frame.size.width, 32);
    searchB.font = [UIFont systemFontOfSize:14];
    searchB.placeholder = @"请输入要搜索的内容";
    self.navigationItem.titleView = searchB;
}

/**
 *  cell每组显示数据
 */
-(void)setupItems
{
    //0组
    CMJCommonGroup *group0 = [self addGroup];
    CMJCommonArrowItem *hotStatus = [CMJCommonArrowItem itemWithTitle:@"热门微博" icon:@"hot_status"];
    hotStatus.subttile = @"笑话，娱乐，神最右都搬到这啦";
    hotStatus.operation = ^{
        NSLog(@"点击了热门微博");
    };
    
    CMJCommonArrowItem *findPeople = [CMJCommonArrowItem itemWithTitle:@"找人" icon:@"find_people"];
    findPeople.subttile = @"名人、有意思的人尽在这里";
    
    group0.items = @[hotStatus,findPeople];
    
    //1组
    CMJCommonGroup *group1 = [self addGroup];
    CMJCommonArrowItem *gameCenter = [CMJCommonArrowItem itemWithTitle:@"游戏中心" icon:@"game_center"];
    CMJCommonArrowItem *near = [CMJCommonArrowItem itemWithTitle:@"周边" icon:@"near"];
    CMJCommonArrowItem *app = [CMJCommonArrowItem itemWithTitle:@"应用" icon:@"app"];
    
    group1.items = @[gameCenter,near,app];
    
    //2组
    CMJCommonGroup *group2 = [self addGroup];
    
    CMJCommonArrowItem *video = [CMJCommonArrowItem itemWithTitle:@"视频" icon:@"video"];
    CMJCommonArrowItem *music = [CMJCommonArrowItem itemWithTitle:@"音乐" icon:@"music"];
    CMJCommonArrowItem *movie = [CMJCommonArrowItem itemWithTitle:@"电影" icon:@"movie"];
    CMJCommonArrowItem *cast = [CMJCommonArrowItem itemWithTitle:@"播客" icon:@"cast"];
    CMJCommonArrowItem *more = [CMJCommonArrowItem itemWithTitle:@"更多" icon:@"more"];
    more.destVc = [MoreController class];
    
    group2.items = @[video,music,movie,cast,more];
}
@end
